import axios from 'axios';
import * as constants from './constants';


const changeLoginState = (value)=>({
	type: constants.CHANGE_LOGIN,
	value
});

export const logout = () =>({
	type: constants.LOGOUT,
	value: false
})

export const login = (account, password)=>{
	return (dispatch)=>{
		axios.get('/api/login.json?account='+account+'&password='+password).then((res)=>{
			console.log(res.data.success);
			const result = res.data.success;
			if(result){
				dispatch(changeLoginState(result));
			} else {
				console.log('登录异常！');
			}
		});
	}
};